<?php
/**
 * Created by PhpStorm.
 * User: LAI
 * Date: 3.8.14
 * Time: 12.36
 */

include_once("../functions/db_functions.php");

function login_handler()
{

  $linkId = 0;
  db_for_IShop_connect($linkId);

  $resultSet = mysql_query("select password from users where name = '" . $_POST['username'] . "'");

  $name = mysql_fetch_array($resultSet);

  if ($name['password'] == $_POST['password']) {
    session_start();
    $_SESSION['login'] = 1;
    db_for_IShop_close($linkId);
    header("Location:http://localhost/IShop.com/main_pg.php");
    die;
  }

  db_for_IShop_close($linkId);
  header("Location:http://localhost/IShop.com/nonlogined_main_page.php");
}

login_handler();